import axios from "axios";

const instance = axios.create({
//   baseURL: 'https://some-domain.com/api/',
  timeout: 1000,
//   headers: {'X-Custom-Header': 'foobar'}
});

instance.interceptors.request.use(function (config) {
    // Do something before request is sent
    let token = localStorage.getItem('token')
    return config;
  }, function (error) {
    // Do something with request error
    return Promise.reject(error);
  });


instance.interceptors.response.use(function (response) {
    if(response.status == 200){
        console.log("状态码200 链接成功");
    }
    return response;
  }, function (error) {
    if(error.status == 401){
        console.log("状态码401 登录过期");
    }
    if(error.status == 403){
        console.log("状态码403");
    }
    if(error.status == 500){
        console.log("状态码500 服务器没开");
    }
    return Promise.reject(error);
  });

  export default instance

